var medal = {};

medal.config = {
	"msg": "error",
}

medal.init = function(opstion){
	var _html = "";
	var img = "";
	var imgArray = ["img/medal-ok.png","img/medal-error.png","img/medal-warning.png"];
	$.extend(true, medal.config, opstion);
	
	if(medal.config.msg == "success"){
		img = imgArray[0];
	}else if(medal.config.msg == "error"){
		img = imgArray[1];
	}else if(medal.config.msg == "warning"){
		img = imgArray[2];
	}
	
	_html +='<div class="modalBk"></div>';
	
	if(medal.config.msg == "warning"){
		_html +='<div class="modalContainer" id="modalContainer" style="height:240px">';
		_html +='<div class="msg-modal-heard">';
		_html +='<img src="'+img+'" />';
		_html +='</div>';
		_html +='<div class="msg-modal-icon">';
		_html +='<label>'+medal.config.msg+'</label>';
		_html +='</div>';
		_html +='<div class="msg-modal-footer msg-clear">';
		_html +='<div class="msg-btn msg-modal-floatL msg-color9" onclick="medalClose()">取消</div>';
		_html +='<div class="msg-btn msg-modal-floatR" onclick="medalSunbit()">确定</div>';
		_html +='</div>';
	}else{
		_html +='<div class="modalContainer" id="modalContainer">';
		_html +='<div class="msg-modal-heard">';
		_html +='<img src="'+img+'" />';
		_html +='</div>';
		_html +='<div class="msg-modal-icon">';
		_html +='<label>'+medal.config.msg+'</label>';
		_html +='<p>3秒钟后自动关闭此窗口，如果您不想等待，直接点击确定关闭</p>';
		_html +='</div>';
		_html +='<div class="msg-modal-footer" style="margin-left: 130px;">';
		_html +='<div class="msg-btn" onclick="medalSunbit()">确定</div>';
		_html +='</div>';
	}
	_html +='</div>';
	$("body").append(_html);
	setTimeClose();
}

function medalSunbit(){
	$(".modalBk,.modalContainer").remove();
}


/*3秒定时器自动关闭*/
function setTimeClose(){
	setTimeout(function(){
		$(".modalBk,.modalContainer").remove();
	},3000);
}
